//
//  QQMiniGameWXLoginTokenModel.h
//  QQMiniGameLogin
//
//  Created by guoyanshi on 2023/5/22.
//  Copyright © 2023 tencent. All rights reserved.

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

@class QQMiniGameWXLoginTokenModel;

typedef void(^QQWXLoginComplete) (QQMiniGameWXLoginTokenModel* _Nullable, NSError* _Nullable);

/// 微信登录delegate
@protocol QQMiniGameWXLoginDelegate <NSObject>

/// 获取缓存中的微信accessToken，缓存过期、无效返回空
- (QQMiniGameWXLoginTokenModel * _Nullable)getCacheTokenModel;

/// 通过Refresh接口请求刷新access_token，refreshtoken存在时请求刷新接口
/// - Parameter complete: 刷新接口回调
- (void)refreshWXLoginWithComplete:(QQWXLoginComplete)complete;

/// 根据登录code获取access_token接口
/// - Parameters:
///   - code: 登录code
///   - complete: 完成回调
- (void)sendRequestWithCode:(NSString *)code complete:(QQWXLoginComplete)complete;

/// 清理微信缓存，退出微信登录时会触发
- (void)clearWXTokenCache;
@end

@interface QQMiniGameWXLoginTokenModel : NSObject
@property(nonatomic, copy) NSString *accessToken;
@property(nonatomic, copy) NSString *openID;
@end

NS_ASSUME_NONNULL_END
